package org.edu.action;

import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.interceptor.RequestAware;
import org.edu.model.User;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Controller
@ParentPackage("struts-default")
public class ManagementAction extends ActionSupport implements RequestAware{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4240818020298955427L;
	private Map<String, Object> request;
	@Action(value = "admin", results = { @Result(name = "admin", location = "/examples/index.jsp",type="redirect"),
			@Result(name = "success", location = "/Interface/hello.jsp",type="redirect")})
	public String execute(){
		Map<String,Object> session =  (Map<String,Object>)ActionContext.getContext().getSession();
		User u=(User)session.get("user");
		if("4028b8814bb53e6f014bb53e73dd0000".equals(u.getRoleid().getId()))//超级管理员
			return "admin";
		else
			return SUCCESS;
		
	}
//	
//	@Action(value = "section", results = { @Result(name = "success", location = "/examples/section.jsp") })
//	public String section(){
//		return SUCCESS;
//		
//	}
//	@Action(value = "navigation", results = { @Result(name = "success", location = "/examples/navigation.jsp") })
//	public String navigation(){
//		return SUCCESS;
//		
//	}
//	@Action(value = "Staff", results = { @Result(name = "success", location = "/examples/Staff.jsp") })
//	public String Staff(){
//		return SUCCESS;
//		
//	}
	
	public void setRequest(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		this.request=arg0;
	}

	public Map<String, Object> getRequest() {
		return request;
	}
	
}
